-- show_mask.lua
-- Created by zouyb Jun/05/2015
-- 显示强制指引蒙版窗口

return {
    run = function(id)
        local showMsgList = table.copy(DungeonGuideM.query(id, "p1"));
        local clickEffetArr = DungeonGuideM.query(id, "p2");
        local showPos = DungeonGuideM.query(id, "p3");
        local inEffect = DungeonGuideM.query(id, "in_effect");
        local outEffect = DungeonGuideM.query(id, "out_effect");

        local _, _, targetFormName, targetPath = string.find(DungeonGuideM.query(id, "p4"), "(%a+)%(([%a%d_/]+)%)");

        local clickEffect, offset;
        if type(clickEffetArr) == "table" then
            clickEffect = clickEffetArr[1];
            offset = cc.p(clickEffetArr[2], clickEffetArr[3]);
        end

        -- 显示强制指引蒙版窗口
        local targetForm = UIMgr.getCurrentScene():getFormByName(targetFormName);
        if targetForm ~= nil then
            UIMgr.getCurrentScene():removeFormByName("UIGuideMaskWithDialogue");

            -- UIGuideMask的关闭依赖于目标节点发布的TARGET_CLICK事件
            -- 因此，在目标节点上蒙上蒙版窗口后，需要修改原来目标节点的事件监听函数
            -- 将node:addTouchEventListener(f) 函数改为 AddTouchListener(node, f)
            -- 这样目标节点被点击时可以自动发布TARGET_CLICK事件
            require "game/ui/form/guide/UIGuideMaskWithDialogue";
            local uiGuide = UIGuideMaskWithDialogue.create(targetForm, targetPath, showMsgList, showPos, inEffect, outEffect, clickEffect, offset);
            UIMgr.getCurrentScene():addForm(uiGuide);
            AudioM.playFx("button_tiny");
        end
    end,
};